para mtemp0
   if .not. impressora()
      retu(2)
   endif
   legal(8,6,22,77,'Resumo de Retencoes Federais')
   mmes =  '  /    '
   @ 10,8 say 'Mes/Ano   :' get mmes pict '99/9999'
   read
   if empty(ctod('01/'+mmes))
      mensa(10,'Dados invalidos',2)
      retu  
   endif
   sele 100
   use temp
   mtitulo = .t.
   mpagina = 1
   tcofins := tpis := tpis := tir := tcs := timpostos := ttotal := 0
   gcofins := gpis := gpis := gir := gcs := gimpostos := gtotal := 0
   sele temp          
   go top
   while .not. eof()
    if right(dtoc(recebto),7) # mmes
      skip
      loop
    endif
    if cancela = 'S'
       skip
       loop
    endif
    set devi to screen
    @ 15,8 say 'Data        : ' + dtoc(emissao)
    set devi to printer
    if mtitulo
       tit_rela('RETENCAO FEDERAL A SER COMPENSADA - ' + mtemp0 + ' : ' + mmes,mpagina)
       mtitulo = .f.
       @ prow(),0   say chr(15)
       @ prow()+1,0 say '   DATA DE     NOTA       DATA    VALOR   *                      VALOR RETIDO                           *                '
       @ prow()+1,0 say '   EMISSAO   FISCAL   RETENCAO      N.F.  *     COFINS         PIS        I.R.        C.S.        TOTAL *  ORGAO RETENTOR'
       @ prow()+1,0 say repli('=',132)
       @ prow()+1,0 say ''
    endif
    mcliente = cliente
    sele clientes
    seek mcliente  
    if publico # 'S'           
       sele temp           
       skip
       loop
    endif
    mnome    = nome
    sele temp          
    mretencao1 = acharetencao(1)
    sele temp               
**  mbase     = total - vmaterial
    mbase     = total               
    mir       = mbase * (irrf/100)
    mcofins   = mbase * (cofins/100)
    mpis      = mbase * (pis/100)    
    mcs       = mbase * (csll/100)
    mliquido  = mcofins+mpis+mir+mcs
    ttotal   += mbase 
    tcofins  += mcofins
    tpis     += mpis
    tir      += mir
    tcs      += mcs
    timpostos+= mliquido
    @ prow()+1,0  say dtoc(emissao) + str(numero,8) + '  ' + dtoc(recebto) + trans(mbase,'999999,999.99')
    @ prow(),44   say mcofins   pict '999,999.99'
    @ prow(),56   say mpis      pict '999,999.99'
    @ prow(),68   say mir       pict '999,999.99'
    @ prow(),80   say mcs       pict '999,999.99'
    @ prow(),93   say mliquido  pict '999,999.99'
    @ prow(),108  say left(mnome,26)
    skip
    if prow() > 56
       eject
       mtitulo = .t.
       mpagina+=1
    endif
   enddo
   @ prow()+1,0  say repli('=',132)
   @ prow()+1,0  say 'Sub-Total'                                       
   @ prow(),31   say ttotal    pict '9,999,999.99'
   @ prow(),44   say tcofins   pict '999,999.99'
   @ prow(),56   say tpis      pict '999,999.99'
   @ prow(),68   say tir       pict '999,999.99'
   @ prow(),80   say tcs       pict '999,999.99'
   @ prow(),93   say timpostos pict '999,999.99'
   @ prow()+1,0  say repli('=',132)
   gtotal     = ttotal 
   gcofins   += tcofins
   gpis      += tpis
   gir       += tir
   gcs       += tcs
   gimpostos += timpostos
   tcofins := tpis := tir := tcs := timpostos := ttotal := 0
   go top
   while .not. eof()
    if right(dtoc(recebto),7) # mmes
      skip
      loop
    endif
    if cancela = 'S'
       skip
       loop
    endif
    mretencao4 = acharetencao(4)
    if mretencao4 = 0
       skip
       loop
    endif
    set devi to screen
    @ 15,8 say 'Data        : ' + dtoc(emissao)
    set devi to printer
    if mtitulo
       tit_rela('RETENCAO FEDERAL A SER COMPENSADA - ' + mtemp0 + ' : ' + mmes,mpagina)
       mtitulo = .f.
       @ prow(),0   say chr(15)
       @ prow()+1,0 say '   DATA DE     NOTA       DATA    VALOR   *                      VALOR RETIDO                           *                '
       @ prow()+1,0 say '   EMISSAO   FISCAL   RETENCAO      N.F.  *     COFINS         PIS        I.R.        C.S.        TOTAL *  ORGAO RETENTOR'
       @ prow()+1,0 say repli('=',132)
       @ prow()+1,0 say ''
    endif
    mcliente = cliente
    mbase    = total 
    mcofins   = mbase * (.03)
    mpis      = mbase * (.0065)    
    mcs       = mbase * (.01)    
    mliquido  = mcofins+mpis+mcs
    ttotal   += mbase 
    tcofins  += mcofins
    tpis     += mpis
    tcs      += mcs
    sele clientes
    seek mcliente  
    mnome    = nome
    sele temp              
    timpostos  += mcofins + mpis + mcs
    @ prow()+1,0  say dtoc(emissao) + str(numero,8) + '  ' + dtoc(recebto) + trans(mbase,'999999,999.99')
    @ prow(),44   say mcofins    pict '999,999.99'
    @ prow(),56   say mpis       pict '999,999.99'
    @ prow(),80   say mcs        pict '999,999.99'
    @ prow(),93   say mliquido   pict '999,999.99'
    @ prow(),108  say left(mnome,26)
    skip
    if prow() > 56
       eject
       mtitulo = .t.
       mpagina+=1
    endif
   enddo
   @ prow()+1,0  say repli('=',132)
   @ prow()+1,0  say 'Sub-TOTAL'                                       
   @ prow(),31   say ttotal    pict '9,999,999.99'
   @ prow(),44   say tcofins   pict '999,999.99'
   @ prow(),56   say tpis      pict '999,999.99'
   @ prow(),80   say tcs       pict '999,999.99'
   @ prow(),93   say timpostos pict '999,999.99'
   @ prow()+1,0  say repli('=',132)
   gtotal    += ttotal
   gcofins   += tcofins
   gpis      += tpis
   gcs       += tcs
   gimpostos += timpostos
   @ prow()+1,0  say 'Total Geral'                                     
   @ prow(),31   say gtotal    pict '9,999,999.99'
   @ prow(),44   say gcofins   pict '999,999.99'
   @ prow(),56   say gpis      pict '999,999.99'
   @ prow(),68   say gir       pict '999,999.99'
   @ prow(),80   say gcs       pict '999,999.99'
   @ prow(),93   say gimpostos pict '999,999.99'
   @ prow()+1,0  say repli('=',132)
   eject
   set devi to screen
retu

